package cn.geminis.lowcode.compiler.code;

import cn.geminis.lowcode.compiler.util.JdkTreeMakerUtils;
import com.sun.source.tree.IfTree;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 * @author puddi
 */
@RequiredArgsConstructor
public class LcIf extends AbstractStatement<IfTree> {
    private final AbstractExpression<?> condition;
    private final List<AbstractStatement<?>> then;

    @Override
    protected IfTree createJdkTree() {
        return JdkTreeMakerUtils.ifElse(
                this.condition.getJdkTree(),
                new LcBlock(this.then).createJdkTree()
        );
    }

}
